<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/overlay.css" type="text/css"?>
<?xml-stylesheet href="chrome://zotero-platform/content/zotero.css" type="text/css"?>

<!DOCTYPE window [
	<!ENTITY % editMenuOverlayDTD SYSTEM "chrome://zotero/locale/mozilla/editMenuOverlay.dtd" > %editMenuOverlayDTD;
	<!ENTITY % standaloneDTD SYSTEM "chrome://zotero/locale/standalone.dtd" > %standaloneDTD;
	<!ENTITY % zoteroDTD SYSTEM "chrome://zotero/locale/zotero.dtd"> %zoteroDTD;
]>

<window
	id="pdf-reader"
	windowtype="zotero:reader"
	orient="vertical"
	width="1300"
	height="800"
	persist="screenX screenY width height"
	onclose="reader.close()"
	xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
	xmlns:html="http://www.w3.org/1999/xhtml"
>
	<linkset>
		<html:link rel="localization" href="browser/menubar.ftl"/>
		<html:link rel="localization" href="browser/browserSets.ftl"/>
		<html:link rel="localization" href="toolkit/global/textActions.ftl"/>
		<html:link rel="localization" href="zotero.ftl" />
		<html:link rel="localization" href="reader.ftl" />
	</linkset>

	<script type="application/javascript">
		Services.scriptloader.loadSubScript("chrome://zotero/content/include.js", this);
		Services.scriptloader.loadSubScript("chrome://zotero/content/platformKeys.js", this);
		Services.scriptloader.loadSubScript("chrome://zotero/content/browserWindowShim.js", this);

		// Mozilla scripts
		Services.scriptloader.loadSubScript("chrome://global/content/globalOverlay.js", this);
		Services.scriptloader.loadSubScript("chrome://global/content/contentAreaUtils.js", this);
		if (Zotero.isMac) {
			Services.scriptloader.loadSubScript("chrome://global/content/macWindowMenu.js", this);
		}

		Services.scriptloader.loadSubScript("chrome://zotero/content/editMenuOverlay.js", this);
		Services.scriptloader.loadSubScript("chrome://zotero/content/customElements.js", this);
	</script>

	<commandset id="mainCommandSet">
		<!--FILE-->
		<command id="cmd_quitApplication" oncommand="goQuitApplication(event);"/>
		<command id="cmd_close" oncommand="reader.close()"/>
		
		<!--EDIT-->
		<commandset id="editMenuCommands"/>
		<command id="cmd_find"
			oncommand="document.getElementById('zotero-tb-search').select()"/>

		<!--WINDOW-->
		<command id="minimizeWindow"
				 data-l10n-id="window-minimize-command"
				 oncommand="window.minimize();" />
		<command id="zoomWindow"
				 data-l10n-id="window-zoom-command"
				 oncommand="zoomWindow();" />
	</commandset>
	
	<keyset id="mainKeyset">
		<key id="key_back"/>
		<key id="key_forward"/>
		<key id="key_minimizeWindow"
			 command="minimizeWindow"
			 data-l10n-id="window-minimize-shortcut"
			 modifiers="accel"
			 internal="true"/>
		<key id="key_close" key="&closeCmd.key;" command="cmd_close" modifiers="accel"/>
	</keyset>

	<keyset id="editMenuKeys">
		<key id="key_undo" data-l10n-id="text-action-undo-shortcut" modifiers="accel" command="cmd_undo"/>
		<!-- l10n and modifiers set in platformKeys.js -->
		<key id="key_redo" command="cmd_redo"/>
		<key id="key_cut" data-l10n-id="text-action-cut-shortcut" modifiers="accel" command="cmd_cut"/>
		<key id="key_copy" data-l10n-id="text-action-copy-shortcut" modifiers="accel" command="cmd_copy"/>
		<key id="key_paste" data-l10n-id="text-action-paste-shortcut" modifiers="accel" command="cmd_paste"/>
		<key id="key_delete" keycode="VK_DELETE" command="cmd_delete"/>
		<key id="key_selectAll" data-l10n-id="text-action-select-all-shortcut" modifiers="accel" command="cmd_selectAll"/>
		<key id="key_find" key="&findCmd.key;" modifiers="accel" command="cmd_find"/>
		<key id="key_findAgain" key="&findAgainCmd.key;" modifiers="accel" command="cmd_findAgain"/>
		<key id="key_findPrevious" key="&findAgainCmd.key;" modifiers="shift,accel" command="cmd_findPrevious"/>
		<key id="key_findAgain2" keycode="&findAgainCmd.key2;" command="cmd_findAgain"/>
		<key id="key_findPrevious2" keycode="&findAgainCmd.key2;" modifiers="shift" command="cmd_findPrevious"/>
	</keyset>

	<tooltip id="iframeTooltip" page="true"/>
	<menubar>
		<menu id="fileMenu" label="&fileMenu.label;" accesskey="&fileMenu.accesskey;">
			<menupopup id="menu_FilePopup" onpopupshowing="onFileMenuOpen(event, this)">
				<menuitem
						id="menu_transferFromPDF"
						class="menu-type-reader pdf"
						label="&zotero.pdfReader.transferFromPDF;"
						oncommand="reader.transferFromPDF()"
				/>
				<menuitem
					id="menu_importFromEPUB"
					class="menu-type-reader epub"
					data-l10n-id="reader-import-from-epub"
					oncommand="reader.importFromEPUB()"
				/>
				<menuseparator class="menu-type-reader pdf"/>
				<menuitem class="menu-type-reader pdf" label="&zotero.general.saveAs;" oncommand="reader.export()"/>
				<menuitem data-l10n-id="menu-print" oncommand="reader.print()"/>
				<menuitem label="&zotero.items.menu.showInLibrary;" oncommand="reader.showInLibrary()"/>
				<menuseparator/>
				<menuitem id="menu_close" label="&closeCmd.label;" key="key_close"
						  accesskey="&closeCmd.accesskey;" command="cmd_close"/>
			</menupopup>
		</menu>

		<menu id="edit-menu"  data-l10n-id="menu-edit">
			<!-- goUpdateGlobalEditMenuItems(true) is necessary to update Edit menu when contenteditable is focused -->
			<menupopup id="menu_EditPopup" onpopupshowing="onEditMenuOpen(event, this)">
				<menuitem id="menu_undo"
						  key="key_undo"
						  command="cmd_undo" data-l10n-id="text-action-undo"/>
				<menuitem id="menu_redo"
						  key="key_redo"
						  command="cmd_redo" data-l10n-id="text-action-redo"/>
				<menuseparator/>
				<menuitem id="menu_cut"
						  key="key_cut"
						  command="cmd_cut" data-l10n-id="text-action-cut"/>
				<menuitem id="menu_copy"
						  key="key_copy"
						  command="cmd_copy" data-l10n-id="text-action-copy"/>
				<menuitem id="menu_paste"
						  key="key_paste"
						  command="cmd_paste" data-l10n-id="text-action-paste"/>
				<menuitem id="menu_delete"
						  key="key_delete"
						  command="cmd_delete" data-l10n-id="text-action-delete"/>
				<menuseparator/>
				<menuitem id="menu_selectAll"
						  key="key_selectAll"
						  command="cmd_selectAll" data-l10n-id="text-action-select-all"/>
				<menuseparator class="menu-type-reader pdf"/>
				<menuitem
						id="edit-menuitem-rotate-left"
						class="menu-type-reader pdf"
						label="&zotero.pdfReader.rotatePageLeft;"
						oncommand="reader.rotatePageLeft()"
				/>
				<menuitem
						id="edit-menuitem-rotate-right"
						class="menu-type-reader pdf"
						label="&zotero.pdfReader.rotatePageRight;"
						oncommand="reader.rotatePageRight()"
				/>
			</menupopup>
		</menu>
		<menu id="view-menu" label="&viewMenu.label;" accesskey="&viewMenu.accesskey;">
			<menupopup id="menu_viewPopup" onpopupshowing="onViewMenuOpen(event, this)">
				<!--
				To make presentation mode work it's necessary to set
				full-screen-api.enabled=true
				full-screen-api.allow-trusted-requests-only=false
				and then hide all other visible window elements like toolbar, note sidebar, tabs, etc.
				-->
				<menuitem
					id="view-menuitem-hand-tool"
					class="menu-type-reader pdf"
					label="&zotero.pdfReader.handTool;"
					type="checkbox"
					oncommand="reader.toggleHandTool()"
				/>
				<menuseparator class="menu-type-reader pdf"/>
				<menuitem
					id="view-menuitem-vertical-scrolling"
					class="menu-type-reader pdf"
					label="&zotero.pdfReader.verticalScrolling;"
					type="checkbox"
					oncommand="reader.scrollMode = 0"
				/>
				<menuitem
					id="view-menuitem-horizontal-scrolling"
					class="menu-type-reader pdf"
					label="&zotero.pdfReader.horizontalScrolling;"
					type="checkbox"
					oncommand="reader.scrollMode = 1"
				/>
				<menuitem
					id="view-menuitem-wrapped-scrolling"
					class="menu-type-reader pdf"
					label="&zotero.pdfReader.wrappedScrolling;"
					type="checkbox"
					oncommand="reader.scrollMode = 2"
				/>
				<menuseparator class="menu-type-reader pdf"/>
				<menuitem
					id="view-menuitem-no-spreads"
					class="menu-type-reader pdf epub"
					label="&zotero.pdfReader.noSpreads;"
					type="checkbox"
					oncommand="reader.spreadMode = 0"
				/>
				<menuitem
					id="view-menuitem-odd-spreads"
					class="menu-type-reader pdf epub"
					label="&zotero.pdfReader.oddSpreads;"
					type="checkbox"
					oncommand="reader.spreadMode = 1"
				/>
				<menuitem
					id="view-menuitem-even-spreads"
					class="menu-type-reader pdf"
					label="&zotero.pdfReader.evenSpreads;"
					type="checkbox"
					oncommand="reader.spreadMode = 2"
				/>
				<menuseparator class="menu-type-reader epub"/>
				<menuitem
					id="view-menuitem-scrolled"
					class="menu-type-reader epub"
					type="checkbox"
					label="&zotero.pdfReader.scrolled;"
					oncommand="reader.flowMode = 'scrolled'"
				/>
				<menuitem
					id="view-menuitem-paginated"
					class="menu-type-reader epub"
					type="checkbox"
					label="&zotero.pdfReader.paginated;"
					oncommand="reader.flowMode = 'paginated'"
				/>
				<menuseparator class="menu-type-reader pdf epub"/>
				<menuitem
					id="view-menuitem-zoom-in"
					class="menu-type-reader"
					label="&zotero.pdfReader.zoomIn;"
					oncommand="reader.zoomIn()"
				/>
				<menuitem
					id="view-menuitem-zoom-out"
					class="menu-type-reader"
					label="&zotero.pdfReader.zoomOut;"
					oncommand="reader.zoomOut()"
				/>
				<menuitem
					id="view-menuitem-zoom-reset"
					class="menu-type-reader epub snapshot"
					label="&zotero.pdfReader.zoomReset;"
					oncommand="reader.zoomReset()"
				/>
				<menuitem
					id="view-menuitem-zoom-auto"
					class="menu-type-reader pdf"
					type="checkbox"
					label="&zotero.pdfReader.zoomAuto;"
					oncommand="reader.zoomAuto()"
				/>
				<menuitem
					id="view-menuitem-zoom-page-width"
					class="menu-type-reader pdf"
					type="checkbox"
					label="&zotero.pdfReader.zoomPageWidth;"
					oncommand="reader.zoomPageWidth()"
				/>
				<menuitem
					id="view-menuitem-zoom-page-height"
					class="menu-type-reader pdf"
					type="checkbox"
					label="&zotero.pdfReader.zoomPageHeight;"
					oncommand="reader.zoomPageHeight()"
				/>
				<menuseparator class="menu-type-reader"/>
				<menuitem
					id="view-menuitem-split-horizontally"
					class="menu-type-reader"
					type="checkbox"
					label="&zotero.pdfReader.splitHorizontally;"
					oncommand="reader.toggleHorizontalSplit()"
				/>
				<menuitem
					id="view-menuitem-split-vertically"
					class="menu-type-reader"
					type="checkbox"
					label="&zotero.pdfReader.splitVertically;"
					oncommand="reader.toggleVerticalSplit()"
				/>
			</menupopup>
		</menu>
		<menu
			id="go-menu"
			class="menu-type-reader"
			label="&goMenu.label;"
			accesskey="&goMenu.accesskey;"
		>
			<menupopup id="menu_goPopup" onpopupshowing="onGoMenuOpen(event, this)">
				<menuitem 
					id="go-menuitem-first-page"
					class="menu-type-reader pdf epub"
					label="&zotero.pdfReader.firstPage;"
					oncommand="reader.navigateToFirstPage()"
				/>
				<menuitem
					id="go-menuitem-last-page"
					class="menu-type-reader pdf epub"
					label="&zotero.pdfReader.lastPage;"
					oncommand="reader.navigateToLastPage()"
				/>
				<menuseparator class="menu-type-reader"/>
				<menuitem
					id="go-menuitem-back"
					class="menu-type-reader"
					label="&zotero.pdfReader.back;"
					oncommand="reader.navigateBack()"
				/>
				<menuitem
					id="go-menuitem-forward"
					class="menu-type-reader"
					label="&zotero.pdfReader.forward;"
					oncommand="reader.navigateForward()"
				/>
			</menupopup>
		</menu>
		<menu id="windowMenu"
				data-l10n-id="menu-window-menu">
			<menupopup id="windowPopup" onpopupshowing="onWindowMenuOpen(event, this)">
				<menuseparator/>
				<menuitem command="minimizeWindow" key="key_minimizeWindow"/>
				<menuitem command="zoomWindow"/>
				<!-- decomment when "BringAllToFront" is implemented
                    <menuseparator/>
                    <menuitem label="&bringAllToFront.label;" disabled="true"/> -->
				<menuseparator id="sep-window-list"/>
			</menupopup>
		</menu>
	</menubar>

	<hbox flex="1">
		<vbox id="zotero-reader" flex="1">
			<browser id="reader"
					 tooltip="iframeTooltip"
					 type="content"
					 primary="true"
					 transparent="transparent"
					 src="resource://zotero/reader/reader.html"
					 flex="1"/>
			<popupset id="zotero-reader-popupset">
			</popupset>
		</vbox>
	</hbox>
	
	<popupset>
		<panel
			is="autocomplete-richlistbox-popup"
			type="autocomplete-richlistbox"
			id="PopupAutoComplete"
			role="group"
			noautofocus="true"
			hidden="true"
			overflowpadding="4"
			norolluponanchor="true"
			nomaxresults="true"
		/>
	</popupset>
</window>
